const app = getApp()
Page({
  data: {
    // 默认不显示
    showWxAuth: true,
    su: ''
  },
  async onLoad(options) {
    console.log('su:', options.su)
    await this.setData({
      su: options.su
    })
  },
  onShow() {
    // 如果未授权 进行授权
    if (!wx.getStorageSync('wxauth')) {
      this.setData({
        showWxAuth: false
      })
    } else {
      console.log('跳转时的su', this.data.su)
      wx.switchTab({
        url: '/pages/home/home?su=' + this.data.su
      })
    }
  },
  wxLoginAuth() {
    this.setData({
      showWxAuth: true
    })
    wx.setStorageSync('wxauth', true)
    app.toAutoLogin()
    wx.switchTab({
      url: '/pages/home/home?su=' + this.data.su
    })
  }
})